home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’95
/
Reminder Manager
/
Main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-24
|
6KB
|
203 lines
#include "Lose.h"
#include "Danger.h"
#include "About.h"
#include "Play.h"
#include "MenuOn.h"
#include "DoMenu.h"
#include "Main.h"
#include "Chimer.h"
#include "DebugDisplay.h"
#define NIL 0
char ShowDebugFlag = TRUE; // Show our debug window
char PlayingFlag = FALSE; // Noise in progress flag
char inFrontFlag = TRUE; // Frontmost application flag
short MasterVolume = 100; // How much overall volume
short BallFrequency = 255; // How often new balls are dropped
long Resolution = 5; // How many times to skip before going on
long ResolutionCounter = 0; // Keep track of the times
short wherewasI = 0; // Loop Counter for Play1
unsigned long fudgefactor = 50; // how unstarving before play?
unsigned long fudgefactor2 = 10; // how high load before storm starts brewing?
long starvation = 0; // how often we get execution cycles
unsigned long starvTickCount = 0; // the last time we got an execution chance
long starvIncrement = 1; // the bonus multiplier fudge factor
long starvDecrement = 1; // how many ticks to take off the stack per go-round
long deltastarv = 0;
long nextShower = 1; // the minutes of the next time (with bogus init value)
long showerInterval = 15; // minutes between showers
long showerDuration = 10; // seconds (roughly)
long dissatisfaction = 0; // pressure builds up.
long dissIncrement = 2; // how fast.
long dissDecrement = 2; // how many ticks to take off the stack per go-round
void main()
{
char doneFlag = FALSE;
char Is_A_Dialog;
char stillInGoAway;
char ch;
short code;
short theMenu,theItem;
short chCode;
long mResult;
WindowPtr whichWindow;
EventRecord myEvent;
TEHandle theInput = NIL;
Rect tempRect,OldRect;
Point myPt;
GrafPtr SavePort;
/* Warm up the Mac */
InitGraf(&qd.thePort);
InitFonts();
FlushEvents(everyEvent,0);
InitWindows();
InitMenus();
TEInit();
InitDialogs(NIL);
InitCursor();
InitMyMenus();
InitChimer();
Init_About();
// shut up and play yer guitar
// Open_About();
Init_Play();
do
{
if (PlayingFlag)
Play1();
if (theInput != NIL)
TEIdle(theInput);
SystemTask();
if (WaitNextEvent(everyEvent, &myEvent, 5, nil))
{
code = FindWindow(myEvent.where, &whichWindow);
switch (myEvent.what)
{
case mouseDown:
if (code == inSysWindow) /* Is the event in a DA window? */
{
/* Send event to system to handle */
SystemClick(&myEvent, whichWindow);
}
if (code == inMenuBar) // Menu happening
{
AdjustMenus();
mResult = MenuSelect(myEvent.where);
theMenu = HiWord(mResult);
theItem = LoWord(mResult);
DoMenu(&doneFlag,theMenu,theItem,&theInput);
}
if (code == inContent)
{
if (whichWindow != FrontWindow())
{
SelectWindow(whichWindow);// Select the window, bring to front */
}
else // Window is already selected */
{
SetPort(whichWindow);
switch (GetWRefCon(whichWindow)) // Which window? */
{
case 2:
/* The About window closes when touched */
Close_About();
break;
}
}
} /* inContent */
break; /* End of mouseDown */
case keyDown:
case autoKey:
ch = myEvent.message & charCodeMask;
if (myEvent.modifiers & cmdKey)/* Was CMD key down? */
{
AdjustMenus();
mResult = MenuKey(ch);/* Is it a menu selection? */
theMenu = HiWord(mResult);
theItem = LoWord(mResult);
if (theMenu != 0) /* If it is a menu selection... */
DoMenu(&doneFlag, theMenu, theItem, &theInput);
if (((ch == 'x') || (ch == 'X')) && (theInput != NIL))
TECut(theInput);/* Handle a Cut in a TE area */
if (((ch == 'c') || (ch == 'C')) && (theInput != NIL))
TECopy(theInput);/* Handle a Copy in a TE area */
if (((ch == 'v') || (ch == 'V')) && (theInput != NIL))
TEPaste(theInput);/* Handle a Paste in a TE area */
} /* End of Command key processing */
else if (theInput != NIL) /* Is a TE Running? */
/* Get TextEdit to do it */
TEKey(ch,theInput);
break;
case updateEvt: /* Some window needs updating */
whichWindow = (WindowPtr)myEvent.message;
GetPort(&SavePort);
BeginUpdate(whichWindow);
SetPort(whichWindow);
switch (GetWRefCon(whichWindow))
{
case 2:
Update_About();
break;
case 3:
UpdateDisplay();
break;
}
EndUpdate(whichWindow);
SetPort(SavePort);
break;
case diskEvt: /* Disk inserted event */
if (HiWord(myEvent.message) != 0) /* See if a disk mount error */
{ /* due to unformatted disk inserted */
myEvent.where.h = ((qd.screenBits.bounds.right - qd.screenBits.bounds.left) / 2)
- (304 / 2);
myEvent.where.v = ((qd.screenBits.bounds.bottom - qd.screenBits.bounds.top) / 3)
- (104 / 2);
InitCursor();/* Make sure it has an arrow cursor */
theItem = DIBadMount(myEvent.where, myEvent.message);/* Let the OS handle the diskette */
}
break;
case activateEvt: /* Window activated event */
/* Check if activation, not deactivation */
if ((whichWindow != NIL) && (myEvent.modifiers & activeFlag))
SelectWindow(whichWindow);
break;
default:
break;
} /* End of Switch */
} /* End of GetNextEvent */
} /* End of do */
while (doneFlag == FALSE);
} /* End of MAIN -- non-APPE */